package com.zcxy360.sandtable.util;

import org.apache.shiro.codec.Hex;
import org.apache.shiro.crypto.AesCipherService;
import org.apache.shiro.util.ByteSource;

public class AESUtil {
	
	private static final byte[] DEFAULT_KEY = {2,83,28,20,3,91,8,76,38,29,3,58,18,39,40,92};
	private static final AesCipherService ACS = new AesCipherService();
	private static final Integer KEY_SIZE = 128;
	static{
		ACS.setKeySize(KEY_SIZE);
	}
	
	public static String encryptText(String text){
		ByteSource encrypt = ACS.encrypt(text.getBytes(), DEFAULT_KEY);
		return encrypt.toHex();
	}
	public static String decryptText(String encrptText){
		ByteSource decrypt = ACS.decrypt(Hex.decode(encrptText), DEFAULT_KEY);
		return new String(decrypt.getBytes());
	}
}
